class Food {
  element: HTMLElement;

  constructor() {
    this.element = document.getElementById('food')!;
  }

  // 获取食物x轴坐标
  get x() {
    return this.element.offsetLeft;
  }

  get y() {
    return this.element.offsetTop;
  }

  change() {
    let left = Math.floor(Math.random() * 30) * 10;
    let top = Math.floor(Math.random() * 30) * 10;
    this.element.style.left = `${left}px`;
    this.element.style.top = `${top}px`;
  }
}

export default Food;
